package cc.vvshop.demo2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;

/**
 * Created by tomas on 16-6-16.
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {

    //注入账户操作DAO
    @Autowired
    private AccountDao accountDao;
    /**
     * 转账操作  withOut Transcation
     * @param out 转出的账户
     * @param in 转入的账户
     * @param money 转账的金额
     * @throws
     */
    public void transferNoTranscation(String out, String in,Integer money) {
        accountDao.outMoney(out,money);
        int a=1/0;
        accountDao.inMoney(in,money);
    }
    /**
     * 转账操作 with Transcation
     * @param out 转出的账户
     * @param in 转入的账户
     * @param money 转账的金额
     * @throws
     */
    public void transfer(final String out,final String in,final Integer money) {
        accountDao.outMoney(out,money);
        int a=1/0;
        accountDao.inMoney(in,money);
    }
}
